<?php
/**
 * PHPExcel         PHPExcel插件
 * @package         fgFrame/plugin
 * @author          ForeverGlory@qq.com
 * @license         http://code.google.com/p/fgframe/
 * @copyright       2012 - ?    ForeverGlory
 * @link            plugin/PHPExcel.plugin.php
 * @version         $
 *                  Id:1    plugin/PHPExcel.plugin.php      1   2012-02-17 15:30    ForeverGlory
 *                  $
 */
class PHPExcel_plugin extends plugin
{
    private $phpexcel = null;

    public function initialize()
    {
        $this->phpexcel = $this->load->libPlugin("PHPExcel", "PHPExcel", "", 1, "", ".php");
    }

    public function __call($func, $args)
    {
        return call_user_func_array($this->phpexcel->{$func}, $args);
    }

    /**
     * 获取文件属性
     * @return  phpexcel->getProperties()
     */
    public function getProperties()
    {
        return $this->phpexcel->getProperties();
    }

    /**
     * 设置当前 sheet
     * @param   int     $int    当前sheet
     * @return  sheet
     */
    public function setActiveSheetIndex($int = 0)
    {
        return $this->phpexcel->setActiveSheetIndex($int);
    }

    /**
     * 获取当前 sheet
     * @return  sheet
     */
    public function getActiveSheet()
    {
        return $this->phpexcel->getActiveSheet();
    }

    /**
     * 保存文件
     * @param   string  $filepath   保存路径
     * @param   string  $type       保存文件类型
     */
    public function save($filepath, $type = "")
    {
        if(empty($type))
        {
            $type      = "Excel2007";
        }
        $objWriter = PHPExcel_IOFactory::createWriter($this->phpexcel, $type);
        $objWriter->save($filepath);
    }

}